{% extends "questions/base.html" %}
{% from "layout/errorlist.html" import errorlist %}
{% from "upload/attachments.html" import attachments_form %}
{% from "includes/common_macros.html" import content_editor with context %}
{# L10n: {t} is the title of the question. #}
{% set title = _('Editing an answer | {t} | Firefox Support Forum')|f(t=answer.question.title) %}
{% set classes = 'answers' %}
{% set crumbs = [(url('questions.home'), _('Support Forum')),
                 (url('questions.details', answer.question.id), answer.question.title),
                 (None, _('Edit an answer'))] %}

{% block content %}
  <div class="grid_12">
    <article class="main">
      <div class="edit-answer highlight-box">
        <h2>{{ _('Edit an answer') }}</h2>
        <ul class="info">
          <li>
            <label>{{ _('Created by:') }}</label>
            {{ answer.creator }}
          </li>
          <li>
            <label>{{ _('Created:') }}</label>
            {{ datetimeformat(answer.created, format='longdatetime') }}
          </li>
          {% if answer.updated_by %}
            <li>
              <label>{{ _('Last updated by:') }}</label>
              {{ answer.updated_by }}
            </li>
            <li>
              <label>{{ _('Last updated:') }}</label>
              {{ datetimeformat(answer.updated, format='longdatetime') }}
            </li>
          {% endif %}
          <li>
            <label>{{ _('Question:') }}</label>
            {{ answer.question.title }}
          </li>
        </ul>
        <form action="{{ url('questions.edit_answer', answer.question.id, answer.id) }}" method="post">
          {% csrf_token %}
          {{ errorlist(form) }}

          <div class="form-widget{% if form.content.errors %} invalid{% endif %}">
            {{ content_editor(form.content) }}
          </div>

          {{ attachments_form('questions.Answer', answer.pk, answer.images.all(), settings, request.user) }}

          <div class="form-widget submit">
            <button type="submit" class="btn btn-important">{{ _('Update answer') }}</button>
            <input type="submit" id="preview" name="preview" value="{{ _('Preview Reply') }}"
              data-preview-url="{{ url('questions.answer_preview_async') }}"
              data-preview-container-id="answer-preview"
              data-preview-content-id="id_content" />
            <a href="{{ url('questions.details', answer.question.id) }}">{{ _('Cancel') }}</a>
          </div>
        </form>

        <section id="answer-preview">
          {% if answer_preview %}
            {% include "questions/includes/answer_preview.html" %}
          {% endif %}
        </section>
      </div>
    </article>
  </div>
{% endblock %}

{% block side %}
{% endblock %}
